package com.ds.infra.rpc.core.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * RPC框架全局配置
 *
 * @author WeiShaoying
 */
@Data
@ConfigurationProperties(prefix = "rpc")
public class RpcConfig {

    /**
     * ZooKeeper注册中心地址
     */
    private String zkAddress = "localhost:2181";

    /**
     * 服务端监听端口
     */
    private int serverPort;

    /**
     * 序列化方式 (默认JACKSON)
     * 可选值：JACKSON, PROTOSTUFF, HESSIAN
     */
    private SerializerType serializer = SerializerType.JACKSON;

    /**
     * 服务端工作线程数 (默认CPU核心数*2)
     */
    private int serverWorkerThreads = Runtime.getRuntime().availableProcessors() * 2;

    /**
     * 客户端连接超时(ms) (默认3000ms)
     */
    private int connectTimeout = 3000;

    public enum SerializerType {
        JACKSON,
        PROTOSTUFF,
        HESSIAN
    }
}
